package HLCustomUI;

import HLCode.HLObject;
import HLLib.base.HLGraphics;
import HLLib.base.HLGraphics_H;
import HLLib.base.HLMath;
import HLLib.base.HLString;

public class HLFloatInfo extends HLObject implements HLGraphics_H {
    public HLString name;

    public HLString count;

    public int type;

    public int x;

    public int y;

    public int width;

    public int timer;

    public int timeDelay;

    public int speed;

    public HLFloatInfo() {
        speed = 3;
    }

    public HLString GetCount(int count) {
        HLString tmp = new HLString();
        HLString cc = HLString.ValueOfInt(count);

        if (count >= 0) {
            tmp.SetString("+");
            tmp = tmp.Concat(cc);
        } else {
            tmp = cc;
        }
        return tmp;
    }

    public boolean Logic() {
        if (timeDelay > 0) {
            timeDelay--;
            return false;
        }
        timer++;
        int stringHeight = HLGraphics.StringHeight();
        int yDown = HLMath.Add(y, stringHeight);

        if (yDown > 0) {
            int yu = HLMath.Mod(timer, 2);
            boolean timerMore16 = HLMath.IsMoreThan(timer, 16);
            boolean yuEquil0 = HLMath.IsEqual(yu, 0);
            if (HLMath.And(timerMore16, yuEquil0)) {
                speed++;
            }
            y = HLMath.Subtract(y, speed);
            return false;
        }
        return true;
    }

    public void Render(HLGraphics g) {
        if (timeDelay > 0) {
            return;
        }
        int w1 = HLGraphics.StringWidth(name);
        int a2 = HLGraphics.StringWidth(count);
        int w = HLMath.Add(w1, a2);
        int tmp = width;
        tmp -= w;
        tmp >>= 1;
        int startX = x;
        startX += tmp;
        g.DrawString(name, startX, y, 0xffff00, 0x5c0404, TEXT_STYLE_CROSS);
        startX += w1;
        g.DrawString(count, startX, y, 0xfff8a80f, 0x5c0404, TEXT_STYLE_CROSS);
    }

}
